<template>
  <el-radio-group
    :value="value"
    @input="handlerChange"
    @change="changeValied(formItem)">
    <el-radio
      v-for="(item, index) in selectOptions"
      :key="index"
      :label="item">{{ item }}</el-radio>
  </el-radio-group>
</template>

<script>
export default {
  name: 'ValiRadio',
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    value: {
      type: [String, Number, Boolean], // 验证类型后续可以增加
      default: ''
    },
    formItem: {
      type: Object,
      default: () => ({})
    }
  },
  computed: {
    selectOptions: function() {
      return this.formItem.dataSource.split(',')
    }
  },
  methods: {
    handlerChange(v) {
      this.$emit('change', v)
    },
    changeValied(item) {
      this.$emit('changeValied', item)
    }
  }
}
</script>

<style scoped lang="scss"></style>
